package com.nwpusp.display.views.components;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.view.View;

import com.example.petssports.R;
import com.nwpusp.display.GlobalVar;

public class GameBackGround extends View{
	public Bitmap bgBitmap;
	public Bitmap rtnBitmap;
	public float x;
	public float y;
	public float distance;
	public float width;
	public float height;
	
	public GameBackGround(Context view,float distance){
		super(view);
		this.distance = distance;
		getBitmapSource();
		bgBitmap =  GlobalVar.FixScreen(bgBitmap);
		width = bgBitmap.getWidth();
		height = bgBitmap.getHeight();
		rtnBitmap = setBackground();
	}
	private Bitmap setBackground() { 
		Bitmap newbmp = Bitmap.createBitmap((int)width*3, (int)height, Bitmap.Config.ARGB_8888);  
        Canvas cv = new Canvas(newbmp);    
        cv.drawBitmap(bgBitmap, 0, 0, null); 
        cv.drawBitmap(bgBitmap, width, 0, null); 
        cv.drawBitmap(bgBitmap, width*2, 0, null); 
        cv.save(Canvas.ALL_SAVE_FLAG);  
        cv.restore();  
        return newbmp;   	
	}
	
	public void setLocation(float x ,float y){
		this.x = x;
		this.y = y;
	}
	
	public void setDistance(float distance) {
		this.distance = distance;
	}
	
	private void getBitmapSource(){
		bgBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.gamebackground2);
	}
	
	public Bitmap draw(){
		x--;
		return rtnBitmap;
	}

}
